import base from '../api/base.js'
export default {

	methods:{
		//hasParams 是否需要拼接参数
		imgFilter(img,hasParams=true,filterType=""){
			if(!img.includes('https://')&&img&&base.imgUrl&& !img.includes('/static')){
				return base.imgUrl + img
			}else {
				return img
			}
		},
		//预览
		previewUrls(urls=[],current=''){
			urls = urls.map(this.imgFilter);
			if(current) current = this.imgFilter(current,false,'preview')
			uni.previewImage({
				current,
				urls
			})
		},
		//拨打电话
		goIphone(iphone){
			if(!iphone) return
			uni.makePhoneCall({
				phoneNumber: iphone
			})
		},
		// 门店导航
		mapAddress(item) {
			uni.openLocation({
				latitude: Number(item.latitude),//要去的纬度-地址
				longitude: Number(item.longitude),//要去的经度-地址
				name: item.name,//地址名称
				address: item.address,//详细地址名称
				success: function () {
					console.log('导航成功');
				},
				fail: function (error) {
					console.log(error)
				}
			});
		},
	}
}